<template>
  <div>
    <div class="main_container">
      <div class="banner-box">
        <el-carousel :interval="5000" arrow="always">
          <el-carousel-item v-for="item in lists" :key="item.id">
            <img :src="item.img" alt class="banner-img">
          </el-carousel-item>
        </el-carousel>
      </div>
      <div class="content">
        <div class="section1">
          <div style="background: #4F5B69;" class="part">
            <router-link to="/list?id=1">
              <p>餐饮连锁</p>
              <span>RESTAURANT CHAIN</span>
              <span class="index-icon">&#xe658;</span>
            </router-link>
          </div>
          <div style="background: #01C0A7;" class="part">
            <router-link to="/list?id=2">
              <p>生鲜农贸</p>
              <span>FRESH FARM AND TRADE</span>
              <span class="index-icon">&#xe658;</span>
            </router-link>
          </div>
          <div style="background: #3E53B7;" class="part">
            <router-link to="/list?id=3">
              <p>快消行业</p>
              <span>QUICK ELIMINATION</span>
              <span class="index-icon">&#xe658;</span>
            </router-link>
          </div>
          <div style="background: #00A9DA;" class="part">
            <router-link to="/list?id=4">
              <p>更多行业</p>
              <span>MORE INDUSTRIES</span>
              <span class="index-icon">&#xe658;</span>
            </router-link>
          </div>
        </div>
        <div class="section2">
          <h3>我们为您提供多种不同行业的解决方案</h3>
          <h6>商派作为全国最大的电商服务提供商，沉淀了12年的行业及业态项目经验为300多家顶级品牌及零售企业提供适合的针对性解决方案，帮助企业响应业务变化拓展</h6>
        </div>

        <!-- <div class="section3">
          <ul class="case-box">
            <li v-for="list in articles">
              <img :src="list.pc_thumb" alt class="case-img">
              <!--<h3 class="case-title">{{list.title}}</h3>-->
              <!-- <p class="case-detail">
                <template v-for="v in list.tages">
                  <span>{{v}}</span>
                </template>
              </p>
            </li>
          </ul>
        </div>  -->
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      lists: [],
      activeIndex: "1",
      isDisplay: false,
      articles: []
    };
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    handleScroll() {
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;
      if (scrollTop > 70) {
        this.isDisplay = true;
      } else {
        this.isDisplay = false;
      }
    },
    getSlide: function() {
      var that = this;
      that
        .$http({
          method: "GET",
          url: "/ecdo/slide"
        })
        .then(
          function(res) {
            console.log(res);
            that.lists = res.data;
          },
          function(error) {
            console.log(error);
          }
        );
    },
    getArticles: function() {
      var that = this;
      that
        .$http({
          method: "GET",
          url: "/ecdo/articles"
        })
        .then(
          function(res) {
            console.log(res);
            console.log(123);
            that.articles = res.data;
          },
          function(error) {
            console.log(error);
          }
        );
    }
  },

  created() {
    this.getSlide();
    this.getArticles();
  },

  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
@font-face {
  font-family: "iconfont"; /* project id 962996 */
  src: url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.eot");
  src: url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.eot?#iefix")
      format("embedded-opentype"),
    url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.woff2") format("woff2"),
    url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.woff") format("woff"),
    url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.ttf")
      format("truetype"),
    url("https://at.alicdn.com/t/font_962996_18fhr59oz2g.svg#iconfont")
      format("svg");
}
ul {
  margin: 0;
  padding: 0;
}
li {
  list-style: none;
}
p {
  margin-bottom: 0;
}

.main_container {
  width: 100%;
}
.banner-box {
  width: 100%;
  margin: 0 auto;
}
.banner-img {
  width: 100%;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}
.content {
  width: 1000px;
  position: relative;
  margin: 0 auto;
  z-index: 200;
}
.section1 {
  background: green;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
  margin-top: -70px;
}
.section2 {
  background: #fff;
  padding: 50px 50px 30px 50px;
}
.section2 h3 {
  color: #2975e6;
}
.section3 ul {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
}
.section3 ul li {
  width: 50%;
  position: relative;
  margin-bottom: 10px;
}
.case-box li:nth-child(2n + 1) {
  padding-right: 5px;
}
.case-box li:nth-child(2n) {
  padding-left: 5px;
}
.case-img {
  width: 100%;
}
.case-title {
  position: absolute;
  bottom: 100px;
  padding: 0 50px;
  text-align: center;
  color: #fff;
}
.case-detail {
  position: absolute;
  bottom: 50px;
  padding: 0 50px;
  color: #fff;
  font-size: 12px;
}
.case-detail span:first-child {
  background-color: #000;
  padding: 5px 10px;
}
.case-detail span:last-child {
  background-color: #4f5b69;
  padding: 5px 10px;
}
.part {
  width: 25%;
  height: 160px;
  position: relative;
}
.part p {
  color: #fff;
  font-size: 25px;
  padding: 50px 30px 10px 30px;
}
.part span {
  color: #fff;
  opacity: 0.6;
}
.index-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  font-family: "iconfont";
}
</style>
